home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************\
- Line Input v1.01 (c) 1993 Douglas Peterson
- for use with Fastgraph (tm)
- \****************************************************************************/
-
-
- This is a C library for getting data input in both text and graphics
- modes. It consists of only three functions:
- input_line(), define_parameters(), and restore_default_colors().
-
- I apologize in advance for this documentation, hey i'm a programmer
- right??
-
- Copy the include file FGINPUT.H wherever it is you like your include
- files and the 2 .LIB files: FGINLG.LIB and FGINSM.LIB whereever you
- like your .LIB files. FGINLG.LIB is for the large memory model and
- FGINSM.LIB is for the small memory model. Be sure to link one or the
- other into your code as well as the appropriate Fastgraph (tm) library.
-
- This library is 'Freeware', that is you don't need to pay me for it.
- Questions, suggestions, or problems can be addressed to me via the Dust
- Devil BBS (702) 796-7134 or Software Creations BBS (508) 368-1714. My
- user name is 'Douglas Peterson'.
-
-
-
- /****************************************************************************\
-
- Function Descriptions
-
- \****************************************************************************/
-
- ------------------------------
- void define_parameters(void)
- ------------------------------
-
- Description:
-
- This function MUST be called after a call to fg_setmode() and before
- calling input_line() or restore_default_colors(). It sets up global
- parameters that vary depending on the current video mode. It also calls
- restore_default_colors(). If your only using one video mode throughout
- your program, you will only have to call this function once.
-
- Parameters:
-
- None.
-
- Returns:
-
- None.
-
-
- ----------------------------------------
- int input_line(char *line, char *mask)
- ----------------------------------------
-
- Description:
-
- This is the heart of it all. A Single purpose, multi-mode input
- routine. Pass it a place to store the returned line and a mask and that's
- all there is to it. The (line) string contains the default value shown
- to the user and the mask determines how many characters and even what
- keys can be typed in each character cell. In graphics mode, the left and
- bottom corner of the input box are defined by the current graphics cursor
- position, and in text modes the left column and row are defined by the
- current text cursor position.
-
- Parameters:
-
- char *line
-
- This is the buffer that will contain the characters typed by the
- user. It must be set to "" if you don't want a default value shown when
- the input box appears. For instance if you did:
-
- char name[11]="Douglas";
-
- input_line(name,"Aaaaaaaaaa");
-
- The user would see an input box ten characters long, and the word
- "Douglas" would be displayed highlighted in the box. If the first key
- typed is a printable character (not and arrow key or CR or delete, etc)
- the word "Douglas" disappears and they start editing a blank box. On the
- other hand if they had hit an arrow key, the word "Douglas" would be
- un-highlighted and they would continue editing "Douglas".
-
- If instead you did:
-
- char name[11]="";
-
- input_line(name,"Aaaaaaaaaa");
-
- The user would see an input box ten characters long, but would be
- blank. You MUST not allocate a character array without initializing it
- to something or you will get garbage on the screen. There's no way for
- the code to detect garbage from valid English words.
-
-
- char *mask
-
- The (mask) string determines how many characters can be typed and
- what keys can be hit in each cell.
-
- X Allow any key, force to upper case
- x Allow any key
- # Allow only 0 thru 9 and +-,./
- 9 Allow only 0 thru 9
- N Allow a - z, A - Z, 0 - 9, +-,./ and force to upper case
- n Allow a - z, A - Z, 0 - 9, +-,./
- A Allow a - z, A - Z, and force to upper case
- a Allow a - z, A - Z
- Y Allow only y,Y,n,N and force to upper case
-
- Any invalid mask character will result in the user not being able to
- type any key other than the space bar. Extended keys are allowed, but
- only the left and right arrow keys are considered so they're allowance
- is transparent. Plus all editing keys are always allowed.
-
-
- Editing keys supported:
-
- Carrage return
- Escape
- Backspace
- Delete
- Insert
- Left arrow
- Right arrow
- Home
- End
-
-
- Returns:
-
- 0 If the user pressed Carrage Return
- -1 If the user pressed Escape ((line) is not altered)
- 1 If the (mask) length exceeds the buffer (95 characters)
- 2 If the current video mode is not supported
- 3 If define_parameters() has not been called
-
-
- -----------------------------------
- void restore_default_colors(void)
- -----------------------------------
-
- Description:
-
- This function restores the colors assigned different elements of the
- input box by default. This function is usefull if your program changes
- a number of color elements and you want them restored without worrying
- about which ones have been changed and which have not.
-
-
- Parameters:
-
- None.
-
-
- Returns:
-
- None.
-
-
- /****************************************************************************\
-
- Color And Mode Considerations
-
- \****************************************************************************/
-
-
- --------
- COLORS
- --------
-
- /* Black and White Text mode (7) */
-
- Backcolor = 0
- BackHighlightcolor = 1
- TextNormalcolor = 1
- TextHighlightcolor = 1
-
-
- /* 16 Color Text modes (0 thru 3) */
-
- Backcolor = 8
- BackHighlightcolor = 7
- TextNormalcolor = 7
- TextHighlightcolor = 15
-
-
- /* 2 Color Graphics modes (6, 17) */
-
- BorderRcolor = 0;
- BorderTcolor = 0;
- Backcolor = 0;
- BackHighlightcolor = 1;
- TextNormalcolor = 1;
- TextHighlightcolor = 0;
- Cursorcolor = 1;
-
-
- /* 4 Color Graphics modes (4, 5) */
-
- BorderLcolor = 1;
- BorderBcolor = 1;
- BorderRcolor = 1;
- BorderTcolor = 1;
- Backcolor = 0;
- BackHighlightcolor = 1;
- TextNormalcolor = 3;
- TextHighlightcolor = 3;
- Cursorcolor = 2;
-
-
- /* 16+ Color Graphics modes (13, 14, 16 thru 29)*/
-
- BorderLcolor = 0
- BorderBcolor = 0
- BorderRcolor = 15
- BorderTcolor = 15
- Backcolor = 8
- BackHighlightcolor = 7
- TextNormalcolor = 7
- TextHighlightcolor = 15
- Cursorcolor = 4
-
-
- Descriptions:
-
- BorderTcolor Top side 1 pixel border in graphics modes
- BorderLcolor Left side 1 pixel border in graphics modes
- BorderRcolor Right side 1 pixel border in graphics modes
- BorderBcolor Bottom side 1 pixel border in graphics modes
- Backcolor Normal background color in any mode
- BackHighlightcolor Highlighted background color any mode
- TextNormalcolor Normal color of text in any mode
- TextHighlightcolor Highlighted text color in any mode
- Cursorcolor Color of the cursor in graphics modes
-
-
- -------
- MODES
- -------
-
- Considerations:
-
- Modes 0 thru 7, 13, and 14 can only use TextSize of 8
-
- Mode 16 can only use TextSize of 14 and 16. TextSize is set to 14
- after call to default_parameters().
-
- ----------
- TextSize
- ----------
-
- This variable is 8 by default (14 for mode 16), but can be changed
- to 14 or 16 to increase the size of the font. For larger video modes
- you almost have to increase the size in order to see the characters
- clearly.
-
- TextSize=8;
- TextSize=14;
- TextSize=16;
-
- Are all valid. Remember to change this BEFORE calling input_line().
- Any value other than 8,14, or 16 will be changed to 8 (14 for mode 16).
-
-
-